package org.aeon.gamechatnest.pojo;

import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.*;
import lombok.Data;
import org.aeon.gamechatnest.validated.Add;
import org.aeon.gamechatnest.validated.Update;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;

import java.util.Date;

/**
 * @author: MissingAeon
 * @date: 2024/5/8 11:35
 * @description: 测试实体
 */
@Data
@Schema(description = "测试实体", name = "TestEntity")
@Document("test_entity")
public class TestEntity {

    @Id
    @Schema(description = "编号", name = "id")
    @Null(groups = Add.class, message = "新增时id应该为空")
    @NotNull(groups = Update.class, message = "更新时id不能为空")
    @TableId
    private Long id;

    @Schema(description = "名称", name = "name")
    @NotBlank(groups = {Add.class, Update.class}, message = "名称不能为空")
    private String name;

    @Schema(description = "年龄", name = "age", minimum = "0", maximum = "200")
    @NotNull(groups = {Add.class, Update.class}, message = "年龄不能为空")
    @Min(value = 0, groups = {Add.class, Update.class}, message = "年龄不能小于0")
    // 范围
    private Integer age;

    @Schema(description = "生日", name = "birthDay")
    @NotNull(groups = {Add.class, Update.class}, message = "生日不能为空")
    @Past(groups = {Add.class, Update.class}, message = "生日不能大于当前时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date birthDay;

}
